<?php
/**
 * Create By: PhpStorm
 * User: yihua
 * File: User.php
 * Date: 2017/1/24
 * Time: 0:49
 */
namespace app\home\controller;

use app\home\model\page\user\GetAllUser;
use app\home\model\page\user\GetUserCoupon;
use app\library\PageBase;
use think\Controller;
use think\Request;

class User extends Controller
{
    private $param;

    public function __construct()
    {
        parent::__construct();
        $this->param = Request::instance()->param();
    }

    public function getUserList()
    {
        $obj = new GetAllUser();
        $data = $obj->excute($this->param);
        //return JSON($data);
        //exit;
        $this->assign('data', $data);
        return $this->fetch('home/pages/user/userlist');
    }

    public function getUserCoupon()
    {
        $obj = new PageBase();
        $ret = $obj->checkToken($this->param);
        if (false === $ret) {
            header('Location:/home/loginpage');
            exit;
        }
        return $this->fetch('home/pages/user/usercoupon');
    }

    public function getUserAddress()
    {
        $obj = new PageBase();
        $ret = $obj->checkToken($this->param);
        if (false === $ret) {
            header('Location:/home/loginpage');
            exit;
        }
        return $this->fetch('home/pages/user/useraddress');
    }
}